#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>

using namespace std;

struct TreeNode {
     int val;
     TreeNode *left;
     TreeNode *right;
     TreeNode() : val(0), left(nullptr), right(nullptr) {}
     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 };

class Solution {
public:
    vector<int> largestValues(TreeNode* root) {
        vector<int> ret;
        if (root == nullptr) return ret;
        queue<TreeNode*> qt;
        qt.push(root);
        while (qt.size())
        {
            int num = qt.front()->val;
            int n = qt.size();
            for (int i = 0; i < n; i++)
            {
                TreeNode* t = qt.front();
                qt.pop();
                if (t->left) qt.push(t->left);
                if (t->right) qt.push(t->right);
                num = max(num, t->val);
            }
            ret.push_back(num);
        }
        return ret;
    }
};


int main() {
    return 0;
}